home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / bbs / mhis020.zip / LISTDAYS.MEX < prev    next >
Text File  |  1996-12-09  |  4KB  |  139 lines

  1. #include <max.mh>
  2. #include <input.mh>
  3. #include "callstat.mh"
  4. #include "callcrit.mh"
  5. #include "callers.mh"
  6. #include "float.mh"
  7. #include "callutil.mh"
  8. #include "upchar.mh"
  9. #include "file.mh"
  10.  
  11. #define SECONDS_IN_DAY (86400)
  12.  
  13. #define LEGEND_FILE  "history\\dayslgnd"
  14. #define HELP_FILE    "history\\dayskeys"
  15. #define SPINNER_FILE "history\\spinner"
  16.  
  17. int: more_count;
  18.  
  19. int custom_more () {
  20.   char: key;
  21.   more_count := more_count + 1;
  22.   if (more_count >= usr.len - 1) {
  23.     more_count := 0;
  24.     for (;;) {
  25.       print (COL_LBLUE, "More ", COL_YELLOW, "[Y,n,l,?=help]: ");
  26.       while (kbhit ()) getch ();
  27.       show_file (SPINNER_FILE);
  28.       key := getch ();
  29.       print (COL_CYAN, key,'\n');
  30.       key := upChar (key);
  31.  
  32.            if (key = 'N') {return False;}
  33.       else if (key = 'L') {show_file (LEGEND_FILE);}
  34.       else if (key = '?') {show_file (HELP_FILE);}
  35.       else if ((key = 'Y') or (key = '\r')) {return True;}
  36.       else print ("Sorry... unknown command: ", key, '\n');
  37.       };
  38.     };
  39.   return True;
  40.   }
  41.  
  42.  
  43. void show_call_stats (string: last_date, struct _callstats: stats) {
  44.   if (last_date = "") return;
  45.         print (' ', 
  46.           COL_LGREEN,      last_date,
  47.           COL_LMAGENTA,    strpadleft (itostr(stats.time * 100 / SECONDS_IN_DAY) + "%",8, ' '),
  48.           COL_LRED,        strpadleft (itostr (stats.calls), 6, ' '),
  49.           COL_YELLOW,      strpadleft (itostr (stats.filesup), 5, ' '),
  50.           COL_LBLUE,       strpadleft (itostr (stats.kbup), 7, ' '),
  51.           COL_YELLOW,      strpadleft (itostr (stats.filesdn), 5, ' '),
  52.           COL_LBLUE,       strpadleft (itostr (stats.kbdn), 7, ' '),
  53.           COL_LCYAN,       strpadleft (itostr (stats.read), 7, ' '),
  54.           COL_LMAGENTA,    strpadleft (itostr (stats.posted), 7, ' '),
  55.           COL_MAGENTA,     strpadleft (itostr (stats.paged), 5, ' '),
  56.           "\n");
  57.   }
  58.  
  59.  
  60. void list_days () {
  61.   long: calls;
  62.   char: nonstop;
  63.   struct _callinfo: ci;
  64.   struct _callstats: stats;
  65.   string: last_date;
  66.   int: last_day;
  67.  
  68.   calls := call_numrecs();
  69. //  reset_more(nonstop);
  70.   print (COL_WHITE);
  71.   print ("┌────────┬───────┬─────┬────┬──────┬────┬──────┬──────┬──────┬────┐\n");
  72.   print ("│  Date  │Traffic│Calls│  Uploads  │ Downloads │   Messages  │Page│\n");
  73.   print ("│        │       │     │  #    Kb  │  #    Kb  │ Read   Post │    │\n");
  74.   print ("└────────┴───────┴─────┴────┴──────┴────┴──────┴──────┴──────┴────┘\n");
  75.  
  76.   more_count := 3;
  77.  
  78.   while (call_read(callers.index, ci)
  79.         AND kbhit () = False) {
  80.  
  81.     if (ci.login.date.day <> last_day) {
  82.       if (last_day > 0) {
  83.         show_call_stats (last_date, stats);
  84.         };
  85.       if (custom_more () = False) return;
  86.       last_date := date_string (ci.login.date);
  87.       last_day := ci.login.date.day;
  88.       stats_clear (stats);
  89.       };
  90.  
  91.     if (meets_criteria (ci, callers.criteria)) {
  92.       stats_add (stats, ci);
  93. //      print(COL_LCYAN,    strpad(ci.name,25,' '),
  94. //            COL_LMAGENTA, strpadleft(itostr(ci.task),5,' '),
  95. //            COL_LRED,     strpadleft(itostr(ci.calls),6,' '), ' ',
  96. //            COL_YELLOW,   strpad(time_to_string(ci.login.time),6,' '),
  97. //            COL_WHITE,    strpadleft (itostr (time_online (ci) / 60), 3, ' '), ' ',
  98. //            COL_LBLUE,    strpad(flag_string (ci.flags), 10, ' '),
  99. //            '\n');
  100.       };
  101.     if (callers.forward_search) {
  102.       callers.index := callers.index + 1;
  103.       }
  104.     else {
  105.       callers.index := callers.index - 1;
  106.       };
  107.     }
  108.   show_call_stats (last_date, stats);
  109.   if (kbhit ()) {
  110.     print (COL_WHITE + "Aborted\n");
  111.     while (kbhit ()) getch ();
  112.     };
  113.   if (callers.index >= calls or callers.index < 0) {
  114.     print (COL_WHITE + "End of callers log\n");
  115.     };
  116.   }
  117.  
  118. int main () {
  119.   string: result;
  120.   long: start, end;
  121.   struct _callstats: stats;
  122.  
  123.   read_callers ();
  124.  
  125.   input_str (result, INPUT_NLB_LINE + INPUT_DEFAULT, 0, 80,
  126.     COL_WHITE + "\nEnter call number, date, '=' for current, or <enter> for first: " + COL_CYAN);
  127.  
  128.   if (call_open() = False) {
  129.     print ("Cannot open callers.dat!!\n");
  130.     };
  131.  
  132.   callers.index := caller_index (result);
  133.  
  134.   list_days ();
  135.   call_close ();
  136.   write_callers ();
  137.   }
  138.  
  139.